package com.sc.study.student.controller;

import java.text.ParseException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sc.common.core.domain.model.LoginUser;
import com.sc.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sc.common.annotation.Log;
import com.sc.common.core.controller.BaseController;
import com.sc.common.core.domain.AjaxResult;
import com.sc.common.enums.BusinessType;
import com.sc.study.student.domain.ScStudentInterview;
import com.sc.study.student.service.IScStudentInterviewService;
import com.sc.common.utils.poi.ExcelUtil;
import com.sc.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author sc
 * @date 2022-04-27
 */
@RestController
@RequestMapping("/study/interview")
public class ScStudentInterviewController extends BaseController
{
    @Autowired
    private IScStudentInterviewService scStudentInterviewService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('study:interview:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScStudentInterview scStudentInterview)
    {
        startPage();
        List<ScStudentInterview> list = scStudentInterviewService.selectScStudentInterviewList(scStudentInterview);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('study:interview:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScStudentInterview scStudentInterview)
    {
        List<ScStudentInterview> list = scStudentInterviewService.selectScStudentInterviewList(scStudentInterview);
        ExcelUtil<ScStudentInterview> util = new ExcelUtil<ScStudentInterview>(ScStudentInterview.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('study:interview:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(scStudentInterviewService.selectScStudentInterviewById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('study:interview:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScStudentInterview scStudentInterview) throws ParseException {
        Long userId = SecurityUtils.getUserId();

        return toAjax(scStudentInterviewService.insertScStudentInterview(scStudentInterview));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('study:interview:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScStudentInterview scStudentInterview) throws ParseException {
        return toAjax(scStudentInterviewService.updateScStudentInterview(scStudentInterview));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('study:interview:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scStudentInterviewService.deleteScStudentInterviewByIds(ids));
    }

    /**
     *
     */
    /**
     * 根据学员id查询访谈集合包含访谈人和类型
     */
    @PreAuthorize("@ss.hasPermi('study:interview:list')")
    @GetMapping("/selectScStudentInterviewListByStudentId")
    public TableDataInfo selectScStudentInterviewListByStudentId(ScStudentInterview scStudentInterview)
    {
        startPage();
        List<ScStudentInterview> list = scStudentInterviewService.selectScStudentInterviewListByStudentId(scStudentInterview);
        return getDataTable(list);

    }

}
